// 引入的axios已经配置好基准路径

import axios from '@/utils/myaxios.js';
// import axios from 'axios';

// 1.登陆
export const login = (data) => {
  return axios({
    method: 'post',
    url: '/login',
    data
  });
};

// 2.注册
export const register = (data) => {
  return axios({
    method: 'post',
    url: '/register',
    data
  });
};


// 获取用户详情
// 接口类型:【GET】
// 需要验证:【Authorization 】
// 接口地址:/user/:id
// xhr.setRequestHeader('Conent-Type','applicatio/x-www-form-urlencoded')
export const getUserInfo = (id) => {
  return axios({
    url: `/user/${id}`,
    // headers: { Authorization: localStorage.getItem('hm_toutiao_56') }
  });
};

export const editUser = (id, data) => {
  return axios({
    method: 'post',
    url: `/user_update/${id}`,
    data
  });
};

// 关注用户
export const user_follows = (id) => {
  return axios({
    url: `/user_follows/${id}`
  });
};

// 取消关注用户
export const user_unfollow = (id) => {
  return axios({
    url: `user_unfollow/${id}`
  });
};

// 用户关注列表
export const user_followList = () => {
  return axios({
    url: `/user_follows`
  });
};

// 取消用户关注列表
export const user_unfollowList = (id) => {
  return axios({
    url: `/user_unfollow/${id}`
  });
};

// 用户收藏列表
export const user_starList = (id) => {
  return axios({
    url: `/user_star`
  });
};